﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Configuration;
using DropBoxClient.Entities;

namespace DropBoxClient.Tests
{
    [TestClass]
    public class GetFolderMetaTest
    {
        private string accessToken;
        private FolderMeta folderMeta;

        [TestInitialize]
        public void Init()
        {
            accessToken = ConfigurationManager.AppSettings["AccessToken"];
            var client = new OAuth2Client(accessToken);
            folderMeta = client.GetFolderMeta(StringConstants.SandboxRoot, "Test");
        }

        [TestMethod]
        public void GetFolderMeta_ResultIsNotNull()
        {
            Assert.IsNotNull(folderMeta);
        }

        [TestMethod]
        public void GetFolderMeta_BytesIsZero()
        {
            Assert.IsTrue(folderMeta.Bytes == 0);
        }

        [TestMethod]
        public void GetFolderMeta_IsADirectory()
        {
            Assert.IsTrue(folderMeta.IsDirectory);
        }

        [TestMethod]
        public void GetFolderMeta_ReturnsMetaList()
        {
            Assert.AreEqual(3, folderMeta.Contents.Count);
        }

        [TestMethod]
        public void GetFolderMeta_HasFolderMetaInMetaList()
        {
            var client = new OAuth2Client(accessToken);
            var folderMeta = client.GetFolderMeta(StringConstants.SandboxRoot, "Test");
            Assert.IsTrue(folderMeta.Contents.Where(x => x.IsDirectory).Any());
        }
    }
}
